<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/9/14
  Time: 19:38
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>ERP系统 - 合同信息更新</title>
    <link rel="stylesheet" href="<%=request.getContextPath()%>/static/css/main.css">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/static/lib/font-awesome/css/font-awesome.css">
    <script type="text/javascript" src="<%=request.getContextPath()%>//static/lib/jquery/jquery.js"></script>
    <script type="text/javascript">
        function checkd(e){
            var mach = /^([1-9]\d*(\.\d*[1-9])?)|(0\.\d*[1-9])$/;
            if(mach.test(e.val())){
                e.next().text("");
                return true;
            }else{
                e.next().text("需要输入整数或数字");
                return false;
            }
        }
        function checkMoney(){
            return checkd($("input[name=cRental]"));
        }
        function checkCash(){
            return checkd($("input[name=cCash]"))
        }
        function overCheck(){
            return checkMoney()&&checkCash();
        }
    </script>
</head>
<body>
    <div class="box">
        <h3>修改合同信息</h3>
        <form action="<%=request.getContextPath()%>/contract/save" method="post" onsubmit="return overCheck()">
            <table class="form-table">
                <tr>
                    <td>合同编号:</td>
                    <td colspan="3" class="control">
                        ${contract.cId}
                        <input type="hidden" name="cId" value="${contract.cId}">
                    </td>
                </tr>
                <tr>
                    <td>合同租户姓名</td>
                    <td colspan="3" class="control">
                        <select name="lId" >
                            <c:forEach var="list" items="${lessee}" varStatus="status">
                                <option value="${list.lId}" ${contract.lessee.lName == list.lName ?'selected':''}>${list.lName}</option>
                            </c:forEach>
                        </select>
                    </td>
                </tr>

                <tr>
                    <td>合同失效时间</td>
                    <td colspan="3" class="control">
                        <input type="date" name="overtime" placeholder="合同失效时间" value="${contract.cOvertime}">
                    </td>
                </tr>

                <tr>
                    <td>房租总额</td>
                    <td colspan="3" class="control">
                        <input type="text" name="cRental" placeholder="房租总额" onblur="checkMoney()" value="${contract.cRental}">&nbsp;
                        <span style="color: red"></span>
                    </td>
                </tr>
                <tr>
                    <td>房租支付方式</td>
                    <td colspan="3" class="control">
                        <input type="text" name="cCash" placeholder="房租支付方式" onblur="checkCash()" value="${contract.cCash}">&nbsp;
                        <span style="color: red"></span>
                    </td>
                </tr>


            </table>
            <div class="buttons">
                <input class="btn btn-primary va-bottom" type="submit" value="保存">&nbsp;&nbsp;
                <a class="btn btn-default" href="javascript:history.go(-1)">返回</a>
            </div>
        </form>
    </div>
</body>
</html>
